package calorie.com.calorie.contact;

import android.content.Context;


import com.lxh.baselibray.mvp.BasePresent;
import com.lxh.baselibray.mvp.IBaseView;
import com.lxh.baselibray.net.NetCallBack;
import com.lxh.baselibray.net.ServiceGenerator;
import com.lxh.baselibray.util.Md5Utils;
import com.lxh.baselibray.util.SPUtils;
import com.lxh.baselibray.util.ToastUtils;


import calorie.com.calorie.api.ApiService;
import calorie.com.calorie.constant.Constant;
import calorie.com.calorie.request.DrawCoinRequest;
import calorie.com.calorie.response.DrawCoinResponce;
import retrofit2.Call;
import retrofit2.Response;

public class DrawCoinContact {
    public static class DrawCoinPresent extends BasePresent<IDrawCoinView> {
        public void drawCoin(Context context,double tokenNum,String dealPwd,String type){
            ApiService service= ServiceGenerator.createService(ApiService.class);
            int userId= SPUtils.getInt(Constant.USER_ID,-1,context);
            DrawCoinRequest request=new DrawCoinRequest(tokenNum,type, Md5Utils.stringToMD5(dealPwd),userId);
            service.drawCoin(request).enqueue(new NetCallBack<DrawCoinResponce>() {
                @Override
                public void onSuccess(Call<DrawCoinResponce> call, Response<DrawCoinResponce> response) {
                    if (getView()!=null){
                        getView().getDrawCoinData(response);
                    }
                }

                @Override
                public void onFailed() {
                    //ToastUtils.showLongToast(context,"网络请求异常");
                }
            });
        }

    }
    public interface IDrawCoinView extends IBaseView {
        void getDrawCoinData(Response<DrawCoinResponce> response);
    }
}
